﻿using AdverseEventReportSystem.BLL.ServiceReference1;
using AdverseEventReportSystem.Core;
using AdverseEventReportSystem.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdverseEventReportSystem.BLL
{
    public class PositionManager : BaseManager
    {
        /// <summary>
        /// 添加/编辑
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        public static OperateResult Save(tb_Position position)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
                ResultHelperOfBoolean result = service.SavePosition(position);
                if (!result.S)
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static OperateResult Delete(int id)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
                ResultHelperOfBoolean result = service.DeletePosition(id);
                if (!result.S)
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }
    }
}
